<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深拷贝算法</title>
</head>
<body>
    
</body>
<script>
    // 什么是浅拷贝、什么是深拷贝？



    function deepClone(targetObj) {
        if(typeof targetObj === 'object' && targetObj !== null){
            let result = Array.isArray(targetObj)?[]:{}
            for(let key in targetObj) {
                if(targetObj.hasOwnProperty(key)) {
                    result[key] = deepClone(targetObj[key])
                }
            }
        } else {
            return targetObj
        }
    }
</script>
</html>